package com.d0311hm;

import java.util.Scanner;

public class Rent {
    public static void main(String[] args) {
        //对各类车实例化并保存到cars数组
        Car[] cars={
                new PassageCar("\t奥迪A4\t\t",4,500),
                new PassageCar("\t马自达6\t\t",4,400),
                new Pickup("\t皮卡雪6\t\t",4,2,450),
                new PassageCar("\t金龙\t\t\t",20,800),
                new Truck("\t松花江\t\t",4,400),
                new Truck("\t依维柯\t\t",20,1000)};
        System.out.println("****欢迎使用达达租车系统！****");
        System.out.println("****您确认租车吗？****"+"\n"+"是（请输入1） \t 否（请输入2）");

        Scanner in1=new Scanner(System.in);
        int is=in1.nextInt();
        if(is!=1){
            System.out.println("****欢迎下次光临！****");
            System.exit(0);
        }
        if(is==1){
            System.out.println("****您可租车的类型及价目表****");
            System.out.println("序号"+"\t\t车名"+"\t\t载客数（人）"+"\t载货量（吨）"+"\t日租金（元/天）");

            //使用循环方式将各类车输出
            for(int i=0;i<cars.length;i++){
                System.out.println((i+1)+"\t"+cars[i]);
            }



            System.out.println("****请输入您的租车数量：****");
            int num1=in1.nextInt();
            Car[] rentcar=new Car[num1];
            int price=0;//总价格
            int totalpeople=0;//总人数
            int totalloads=0;//总载货量


              //  System.out.println("****请输入第"+(i+1)+"辆车的序号：****"+"****请输入天数：****"+);
            System.out.println("请输入您要租车的序号和天数");
            int[] m = new int[num1];
            int[] n = new int[num1];

            for (int i = 0; i < num1; i++) {
                m[i] = in1.nextInt();
                n[i] = in1.nextInt();
            }
            //System.out.println("****请输入天数：****");

            System.out.println("****您的账单：****");
            System.out.println("已选载人车：");
            for(int i=0;i<num1;i++){
                if(rentcar[i].people!=0){
                    System.out.println(rentcar[i].name+"\t");
                }

                totalpeople=totalpeople+rentcar[i].people;
            }

            System.out.println('\n');
            System.out.println("已选载货车：");
            for(int i=0;i<num1;i++){
                if(rentcar[i].loads!=0){
                    System.out.println(rentcar[i].name+"\t");
                }

                totalloads=totalloads+rentcar[i].loads;
            }


            System.out.println('\n');
            System.out.println("共载客："+totalpeople+"人");
            System.out.println("共载货："+totalloads+"吨");
            System.out.println("租车总价格："+price+"元");
            System.out.println('\n');
            System.out.println("****感谢您的惠顾，欢迎再次光临！****");

        }
    }
}